//
//  UIButton+Extension.m
//  weibo110
//
//  Created by 臧松 on 15/12/26.
//  Copyright © 2015年 臧松. All rights reserved.
//

#import "UIButton+Extension.h"

@implementation UIButton (Extension)
+(instancetype)btnWithImageName:(NSMutableString *)imageName backImageName:(NSMutableString *)backImageName{
    UIButton * btn = [[UIButton alloc]init];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:[imageName stringByAppendingFormat:@"_highlighted"]] forState:UIControlStateHighlighted];
    [btn setBackgroundImage:[UIImage imageNamed:backImageName] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:[backImageName stringByAppendingFormat:@"_highlighted"]] forState:UIControlStateHighlighted];
    // 自动调整按钮大小
    [btn sizeToFit];
    return btn;
}
+(instancetype)btnWithTitle:(NSString*)title color:(UIColor*)color imageName:(NSString*)imageName{
    
   UIButton* btn = [[UIButton alloc]init];
    [btn setTitle:title forState: UIControlStateNormal];
    [btn setTitleColor:color forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn sizeToFit];
    return btn;
}
+(instancetype)btnWithTitle:(NSString *)title color:(UIColor *)color imageName:(NSString *)imageName fontSize:(CGFloat)fontSize{
    
    UIButton* btn = [[UIButton alloc]init];
    [btn setTitle:title forState: UIControlStateNormal];
    [btn setTitleColor:color forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:fontSize];
    [btn sizeToFit];
    return btn;

}
@end
